package com.qth.valet.common.utils;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

public class ToolUtils {

    public static String generateOrder(){
        return DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmssSSS")
                + ( new Random().nextInt(900) + 100 );
    }

    public static int generateVerifyCode(){
        return new Random().nextInt(9000)+1000;
    }

    public static String generateDriverOrderId(){
        return DateUtil.format(LocalDateTime.now(), "yyyyMMddHHmmssSSS")
                + ( new Random().nextInt(900) + 100 );
    }

    public static boolean isWithinRange() {
        // 确保开始时间在结束时间之前
        LocalTime time = LocalTime.now();
        LocalTime start = LocalTime.of( 7, 0, 0);
        LocalTime end = LocalTime.of(21, 59, 59);
        if (start.isAfter(end)) {
            LocalTime temp = start;
            start = end;
            end = temp;
        }
        return !time.isBefore(start) && !time.isAfter(end);
    }

    public static void main(String[] args) {
        DateTime dateTime = DateUtil.offsetMinute(new Date(), 60);
        System.err.println(DateUtil.format(dateTime, "yyyy-MM-dd HH:mm:ss"));
    }

}
